<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace core\lib;

/**
 * Description of config
 *
 * @author gangguo
 */
class config {
    //put your code here
    
    static public $conf = array();


    static public function get($name,$file='config'){
        if(isset(self::$conf[$file])){
            return self::$conf[$file][$name];
        }else{
            $path = CORE.'/conf/'.$file.'.php';
            if(is_file($path)){
                $conf = include $path;
                if(isset($conf[$name])){
                    self::$conf[$file] = $conf;
                    return $conf[$name];
                }else{
                    throw new \Exception('没有配置选项:'.$name);
                }
            }else{
                throw new \Exception('没有找到配置文件:'.$path);
            }
        }
    }
    
    static public function all($file){
        if(isset(self::$conf[$file])){
            return self::$conf[$file];
        }else{
            $path = CORE.'/conf/'.$file.'.php';
            if(is_file($path)){
                $conf = include $path;
                    self::$conf[$file] = $conf;
                    return $conf;
            }else{
                throw new \Exception('没有找到配置文件:'.$path);
            }
        }
    }
}
